package com.bytesizedhosting.api.android.darthcrap.screens.maintabs;

import java.text.DecimalFormat;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.bytesizedhosting.api.android.darthcrap.ExtendedActivity;
import com.bytesizedhosting.api.android.darthcrap.R;
import com.bytesizedhosting.api.android.darthcrap.api.APIController;

public class ProfileTab extends ExtendedActivity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.profiletab);
        
        String strAccountName = APIController.getData().getLogin();
        double dblBalance = APIController.getData().getBalance();
        
        DecimalFormat objNumberFormat = /*(DecimalFormat)NumberFormat.getCurrencyInstance();
        objNumberFormat.setMinimumFractionDigits(2);
        objNumberFormat.setCurrency(Currency.getInstance("EUR"));
        objNumberFormat.setNegativePrefix("-");
        objNumberFormat.setGroupingUsed(true);
        */ new DecimalFormat("€#,##0.00;€-#,##0.00");
        
        ((TextView)findViewById(R.id.lblAccountName)).setText(strAccountName);
        ((TextView)findViewById(R.id.lblCurrentBalance)).setText(objNumberFormat.format(dblBalance));
        
        int intBalanceAdviseViewID = 0;
        if (dblBalance > 0) {
        	intBalanceAdviseViewID = R.id.lblBalanceOK;
        }
        else if (dblBalance < 0) {
        	intBalanceAdviseViewID = R.id.lblBalanceWarning;
        }
        else {
        	intBalanceAdviseViewID = R.id.lblBalanceAdvisable;
        }
        
        ((TextView)findViewById(intBalanceAdviseViewID)).setVisibility(View.VISIBLE);
    }
}